package org.EmploiDuTemps;

import java.io.Serializable;
import java.util.GregorianCalendar;

@SuppressWarnings("serial")
public class Cour implements Serializable{
	private String name;
	private String room;
	private String prof;
	private GregorianCalendar startTime;
	private GregorianCalendar endTime;
	private long activityID;
	private int duration; // nb de blocs de 15 minutes
	private int color;

	public Cour() {
	}
	
	public Cour(String name, String room, GregorianCalendar startTime,
			GregorianCalendar endTime, long activityID, int duration) {
		super();
		this.name = name;
		this.room = room;
		this.startTime = startTime;
		this.endTime = endTime;
		this.activityID = activityID;
		this.duration = duration;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getRoom() {
		return room;
	}

	public void setRoom(String room) {
		this.room = room;
	}

	public GregorianCalendar getStartTime() {
		return startTime;
	}

	public void setStartTime(GregorianCalendar startTime) {
		this.startTime = startTime;
	}

	public GregorianCalendar getEndTime() {
		return endTime;
	}

	public void setEndTime(GregorianCalendar endTime) {
		this.endTime = endTime;
	}

	public long getActivityID() {
		return activityID;
	}

	public void setActivityID(long activityID) {
		this.activityID = activityID;
	}

	public int getDuration() {
		return duration;
	}

	public void setDuration(int duration) {
		this.duration = duration;
	}

	public void setProf(String prof) {
		this.prof = prof;
	}

	public String getProf() {
		return prof;
	}

	public void setColor(int color) {
		this.color = color;
	}

	public int getColor() {
		return color;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (int) (activityID ^ (activityID >>> 32));
		result = prime * result
				+ ((startTime == null) ? 0 : startTime.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Cour))
			return false;
		Cour other = (Cour) obj;
		if (activityID != other.activityID)
			return false;
		if (startTime == null) {
			if (other.startTime != null)
				return false;
		} else{
			if (other.startTime instanceof GregorianCalendar ){
				if (! ( ((GregorianCalendar)other.startTime).get(GregorianCalendar.MINUTE) == startTime.get(GregorianCalendar.MINUTE)
					&& ((GregorianCalendar)other.startTime).get(GregorianCalendar.HOUR_OF_DAY) == startTime.get(GregorianCalendar.HOUR_OF_DAY))){
					
					return false;
				}
				
			}
		}
		return true;
	}

	
	
	
}
